package export.magicWeapon
{
	import base.BaseBitmapDataClip;
	import base.BaseBitmapDataPool;
	import base.BaseBullet;
	import base.BaseHero;
	import base.BaseMagicWeapon;
	
	import com.game.data.vo.EquipmentVO;
	
	import export.bullet.SpecialEffectBullet;
	import export.bullet.ThroughWallBullet;
	
	import flash.events.Event;
	import flash.geom.Point;
	
	public class MagicSword extends BaseMagicWeapon
	{
		
		public function MagicSword(param1:BaseHero)
		{
			super(param1);
			this.mp = 30;
		}
		
		private var swordEffect:BaseBullet;
		
		override protected function initBBDC():void
		{
			var _lc1_:* = null;
			var _lc2_:Array = BaseBitmapDataPool.getBitmapDataArrayByName("MagicSwordBmd");
			if (_lc2_)
			{
				_lc1_ = {
					"name"  : "body",
					"source": _lc2_
				};
				bbdc = new BaseBitmapDataClip([_lc1_], 2 * 60, 2 * 60, new Point(0, 0));
				bbdc.setOffsetXY(0, 0);
				bbdc.setFrameStopCount([[10], [9999]]);
				bbdc.setFrameCount([1, 1]);
				bbdc.setAddScriptWhenFrameOver(scriptFrameOverFunc);
				this.addChild(bbdc);
				return;
			}
			throw new Error("MagicSword--BitmapData Error!");
		}
		
		override public function showSkill():void
		{
			var _lc4_:EquipmentVO = null;
			var _lc1_:* = null;
			trace("---showSkill---sword");
			var _lc3_:ThroughWallBullet = new ThroughWallBullet(-18);
			if ((_lc4_ = this.sourceRole.getPlayer().getCurEquipByType("zbfb")).getFiveElementString().indexOf("木") != -1)
			{
				_lc3_.setStopDoubleCount();
			}
			_lc3_.addEventListener("destroy", this.__bulletDestroy, false, 0, true);
//			_lc3_.setUserDataName("MagicUmbrellaHit1");
			_lc3_.x = this.sourceRole.x;
			_lc3_.y = this.sourceRole.y;
			gc.pWorld.getTerrainArray().push(_lc3_);
			gc.gameScene.addChild(_lc3_);
			if (!this.swordEffect)
			{
				_lc1_ = new SpecialEffectBullet("SwordEffect");
				_lc1_.setRole(this.sourceRole);
				_lc1_.setDestroyWhenLastFrame(false);
				_lc1_.setDestroyWhenMaxHitCountLessThenZero(false);
				_lc1_.setAction("fabao-sword");
				_lc1_.setFollowObj(_lc3_);
				this.sourceRole.magicBulletArray.push(_lc1_);
				gc.gameScene.addChild(_lc1_);
				this.swordEffect = _lc1_;
			}
		}
		
		private function __bulletDestroy(param1:Event):void
		{
			trace("---__bulletDestroy---");
			this.setAction("idle");
			if (this.swordEffect)
			{
				this.swordEffect.destroy();
				this.swordEffect = null;
			}
		}
	}
}
